﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace XM
{
    public partial class LK_dl : Form
    {
        public LK_dl()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            while (true)
            {
                if (textBox1.Text == "")
                {
                    DialogResult result;
                    result = MessageBox.Show("请输入登录账号", "输入提示",
                    MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                }
                string zh = textBox1.Text.Trim();
                string mm = textBox2.Text.Trim();
                string admin = comboBox1.Text.Trim();
                int pd = 0;
                if (admin == "管理员")
                {
                    pd = 0;
                }
                else if (admin == "用户")
                {
                    pd = 1;
                }
                else
                {
                    admin = null;
                    MessageBox.Show("请选择用户类型");
                    break;
                }
                if (zh != null && mm != null && admin != null)
                {
                    string sql = string.Format("select * from logon where zh='{0}' and mm='{1}' and admin='{2}'", zh, mm, pd);
                    DataTable lsb = DBhleper.read(sql);
                    if (lsb.Rows.Count > 0)
                    {
                        YZ.LKdl = 1;
                        MessageBox.Show("登录成功");
                        LYH_lb from = new LYH_lb();
                        this.Close();
                        break;

                    }
                    else
                    {
                        MessageBox.Show("登录失败");
                        break;
                    }
                }
            }
        }

        private void LK_dl_Load(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim().Length == 0)
            {
                textBox1.Text = "请输入账号";
            }
        }

        private void textBox1_Enter(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() == "请输入账号")
            {
                textBox1.Text = "";
            }
        }

        private void textBox1_Leave(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim().Length == 0)
            {
                textBox1.Text = "请输入账号";
            }
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            LY_zc zc = new LY_zc();
            zc.Show();
        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            LY_wjmm wjmm = new LY_wjmm();
            wjmm.Show();
        }
    }
}
